<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <!-- 
        目前有三种跨域方法
        第一种： jsonp 利用标签的src属性不存在跨域的特性
        第二种： cors
        第三种： 代理
     -->
     <script>
         function axios(options) {
            return new Promise((resolve, reject) => {
                var xhr = new XMLHttpRequest() // 实例化一个ajax对象
                xhr.open(options.method, options.url, options.async)
                // xhr.setRequestHeader("", "");//设置 http  头信息
                xhr.send()
                xhr.onreadystatechange = function() {
                    if(xhr.readyState === 4 && xhr.status === 200) {
                        let data = xhr.responseText
                        console.log(data)
                        resolve(data)
                    }
                }   
            })
        }

        axios({
            method: 'get',
            url: 'http://127.0.0.1:3000/',
            async: true
        }).then(res => {
            console.log(res)
        })
     </script>
     <!-- jsonp跨域 -->
     <!-- <script>
         function getData(data) {
            console.log(data)
         }
     </script>
     <script src="http://127.0.0.1:3000/"></script> -->
     <!-- <script>
         getData('123')
     </script> -->

     <script>
        function jQuery17206850369972648775_1615341092056(data) {
            console.log(data)
         }
     </script>
     <script src="http://search.yiguo.com/ajax/fullsearch.ashx?datestamp=1615341102373&term=p&jsoncallback=jQuery17206850369972648775_1615341092056"></script>
</body>
</html>